package com.cz.video.framework.config;

import com.cz.video.framework.provider.WordAllowProvider;
import com.cz.video.framework.provider.WordDenyProvider;
import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
import com.github.houbb.sensitive.word.support.allow.WordAllows;
import com.github.houbb.sensitive.word.support.deny.WordDenys;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 敏感词配置
 */
@Configuration
@RequiredArgsConstructor
public class SpringSensitiveWordConfig {


    private final WordAllowProvider wordAllowProvider;

    private final WordDenyProvider wordDenyProvider;

    /**
     * 初始化引导类
     * @return 初始化引导类
     * @since 1.0.0
     */
    @Bean
    public SensitiveWordBs sensitiveWordBs() {
        SensitiveWordBs sensitiveWordBs = SensitiveWordBs.newInstance()
                .wordAllow(WordAllows.chains(WordAllows.defaults(), wordAllowProvider))
                .wordDeny(WordDenys.chains(WordDenys.defaults(),wordDenyProvider))
            //不用默认的词库，有点太离谱了
//            .wordAllow(wordAllowProvider)
//            .wordDeny(wordDenyProvider)
                // 各种其他配置
                .init();
        return sensitiveWordBs;
    }

}
